<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var ThanK = function (nums, k) {
      let n = nums.length, ret = 0;
      let prod = 1, i = 0;
      for (let j = 0; j < n; j++) {
        prod *= nums[j];
        while (i <= j && prod >= k) {
          prod /= nums[i];
          i++;
        }
        ret += j - i + 1;
      }
      return ret;
    };
    console.log(ThanK(nums = [10, 5, 2, 6], k = 100))
  </script>
</body>

</html>